<?php

class sfPropelRevisitedGeneratorConfiguration
{
  static public function getEmbeddedFormFormatterName()
  {
    return sfConfig::get('app_sf_propel_revisited_generator_plugin_embedded_form_formatter_name', 'revisitedEmbedded');
  }

  static public function getFormFormatterName()
  {
    return sfConfig::get('app_sf_revisited_generator_plugin_form_formatter_name', 'revisited');
  }

  static public function getExportationOrientation()
  {
    $opts = self::getExportationConfiguration();
    if (isset($opts['orientation']) && $opts['orientation'] == 'landscape')
    {
      return PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE;
    }

    return PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT;
  }

  static public function getExportationTopMargin()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['top_margin'])? $opts['top_margin'] : 0.393700787;
  }

  static public function getExportationRightMargin()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['right_margin'])? $opts['right_margin'] : 0.393700787;
  }

  static public function getExportationLeftMargin()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['left_margin'])? $opts['left_margin'] : 0.393700787;
  }

  static public function getExportationBottomMargin()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['bottom_margin'])? $opts['bottom_margin'] : 0.393700787;
  }

  static public function getExportationFitToPage()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['fit_to_page'])? $opts['fit_to_page'] : false;
  }

  static public function getExportationFontSize()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['font_size'])? $opts['font_size'] : '9';
  }

  static public function getExportationFontName()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['font_name'])? $opts['font_name'] : 'Arial';
  }

  static public function getExportationPaperSize()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['paper_size'])? $opts['paper_size'] : PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4;
  }

  static public function getExportationCommonTitle()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['common_title'])? $opts['common_title'] : false; 
  }

  static public function getExportationAppendCommonDate()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['append_common_date'])? $opts['append_common_date'] : false;
  }

  static public function getExportationDateFormat()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['date_format'])? $opts['date_format'] : false;
  }

  static public function getExportationConfiguration()
  {
    return sfConfig::get('app_sf_propel_revisited_generator_plugin_exportation', array());
  }

  static public function getNumberOfDecimals()
  {
    return sfConfig::get('app_sf_propel_revisited_generator_plugin_decimals', false);
  }

  static public function getExportationNumberOfDecimals()
  {
    $opts = self::getExportationConfiguration();
    return isset($opts['decimals'])? $opts['decimals'] : false;
  }

  static public function getExportationMaxPerPage()
  {
    $opts       = self::getExportationConfiguration();
    $maxPerPage = isset($opts['max_per_page'])? $opts['max_per_page'] : array('default' => 1000);

    if (is_array($maxPerPage))
    {
      $maxPerPage = array_merge(array('default' => 1000), $maxPerPage);
    }
    elseif (is_numeric($maxPerPage) && $maxPerPage > 0)
    {
      $maxPerPage = array_merge(array('default' => $maxPerPage));
    }

    return $maxPerPage;
  }
}

?>
